
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cglist.css"/>
    <script type="text/javascript" src="/plan/caigou/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/caigou/js/rem.js" ></script>
    <script src="/plan/js/dropload.min.js"></script>

    <title>销售订单列表</title>
</head>
<body>
<style>
    *{
        -webkit-overflow-scrolling: touch;
    }


    .dropload-noData,.dropload-load,.dropload-refresh{
        position: relative;
        margin-top: 0.31rem;
        font-size: 0.22rem;
        width: 1.6rem;
        margin: 0 auto;
        color: grey;
        text-align: center;
    }
    .dropload-noData:after,.dropload-load:after,.dropload-refresh:after {
        content: "";
        position: absolute;
        top: 0.16rem;
        width: 1.01rem;
        height: 1px;
        background-color: #eeeeee;
        right: -1.18rem;
    }

    .dropload-noData:before,.dropload-load:before,.dropload-refresh:before {
        content: "";
        position: absolute;
        top: 0.16rem;
        width: 1.01rem;
        height: 1px;
        background-color: #eeeeee;
        left: -1.2rem;
    }
    .dropload-down{
        display: none;
    }

</style>
{notempty name="arr"}
<div class="top">
    <div class="top_left" style="width: 100%">
        <span class="top_left_con1">仓库</span>
        <img class="top_left_xia1" src="/plan/caigou/img/jtxia.png" />
        <img class="top_left_up1" src="/plan/caigou/img/jtup.png" />
    </div>


</div>
<ul class="company" id="status">

    <li style="color: #457bc7;" dataid="1">全部<img src="/plan/caigou/img/jtyou.png" /></li>
    {volist name="arr" id="vo"}
    <li  dataid="{$vo.id}">{$vo.gname}<img src="/plan/caigou/img/jtyou.png" /></li>
    {/volist}

</ul>
{/notempty}


<div id="mescroll" class="mescroll" {empty name="arr"}style="top:.1rem"{/empty} >
<ul class="cglist" id="pro1" style="margin-bottom: 1rem;overflow-y:scroll ">
</ul>
</div>
<a href="/index/Outpur/xsadd.html"><div class="pay">新增</div></a>
</body>
<script>
    var jsonData={};
    var meLoad;

    var statusPrev = $("#status").children()[0];
    var examinePrev = $(".examine").children()[0];

    $(function(){
        var winHeight = $(window).height();

        var topHeight = $('.top').height();
        var topPadding = parseFloat($('.top').css('padding-top'))*2;
        var conHeight = winHeight-topHeight;
        $("#pro1").height((winHeight-$(".pay").height())+'px');
        $('.company').css({'height':conHeight+'px','top':topHeight+topPadding+1+'px'});
        $('.examine').css({'height':conHeight+'px','top':topHeight+topPadding+1+'px'});
        $('.top_left').click(function(){
            $('.company').toggle();
            $('.examine').hide();
            $('.top_left_xia1').toggle();
            $('.top_left_up1').toggle();
            $('.top_left_xia2').show();
            $('.top_left_up2').hide();
            
            $('.top_left_con1').css('color','#000');
            $('.top_left_con2').css('color','#555');
        });
        $('.company li').click(function(){
            $(statusPrev).css("color","#000");
            $(this).css('color','#457bc7');
            statusPrev = this;
            jsonData.counter=1;
            if ($(this).index()==0){
                //删除自身属性
                if (jsonData.hasOwnProperty("status"))delete jsonData.cid;
            }
            if ($(this).index()!=0)jsonData.cid=$(this).attr("dataid");

            $("#pro1").html('');
            overProduct();
            $('.company').hide();

        });
        $('.top_right').click(function(){
            $('.examine').toggle();
            $('.company').hide();
            $('.top_left_xia2').toggle();
            $('.top_left_up2').toggle();
            $('.top_left_xia1').show();
            $('.top_left_up1').hide();
            $('.top_left_con1').css('color','#555');
            $('.top_left_con2').css('color','#000');
        });
        $('.examine li').click(function(){
            $(examinePrev).css("color","#000");
            $(this).css('color','#457bc7');
            examinePrev = this;
            jsonData.counter=1;
            if ($(this).index()==0){
                //删除自身属性
                if (jsonData.hasOwnProperty("supplier"))delete jsonData.supplier;
            }
            if ($(this).index()!=0)jsonData.supplier=$(this).attr("dataid");

            $("#pro1").html('');
            overProduct();
            $('.company').hide();
            $('.top_left_xia2').show();
            $('.top_left_up2').hide();
            $('.examine').hide();
        });
        $('.sou').click(function(){
            $('.cate_mid').show();
            $('.examine').hide();
            $('.company').hide();
            $('.top_left_up1').hide();
            $('.top_left_xia1').show();
            $('.top_left_up2').hide();
            $('.top_left_xia2').show();
            $('.top_left_con1').css('color','#555');
            $('.top_left_con2').css('color','#555');
        });
        $("#list_search_submit").click(function () {
            let seVal = $("#keyword").val();
            if (seVal==''){
                layer.open({
                    content:'关键词不能为空' ,
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
            }
            if (jsonData.hasOwnProperty("status"))delete jsonData.status;
            if (jsonData.hasOwnProperty("supplier"))delete jsonData.supplier;
            $(examinePrev).css("color","#000");
            $(statusPrev).css("color","#000");
            $("#status").find("li").eq(0).css('color','#457bc7');
            $(".examine").find("li").eq(0).css('color','#457bc7');
            jsonData.counter=1;
            jsonData.title=seVal;
            $("#pro1").html('');
            overProduct();
            $('.company').hide();

        });
        $('.close').click(function(){
            let seVal = $("#keyword").val();
            if (seVal!='' && jsonData.hasOwnProperty("title")!=false){
                delete jsonData.title;
                jsonData.counter=1;
                $("#pro1").html('');
                overProduct();
            }
            $('.cate_mid').hide();
        });
    });
    jsonData.counter=1;
    initList();
    function initList() {
        $('.dropload-down').remove();
        // 每页展示4个
        var num = 4;
        var pageStart = 1,pageEnd = 0;
        // dropload
        meLoad =  $('#pro1').dropload({
            scrollArea : window,
            loadDownFn : function(me){

                $.ajax({
                    type:"post",
                    url:"/index/outpur/xsindex",
                    data:jsonData,
                    success:function (data) {
                        pageEnd = num * jsonData.counter;
                        pageStart = pageEnd - num;
                        if (data.list!=null){
                            let str=getList(data.list);
                            if (jsonData.counter==1 && data.list.length==0){
                                str='<img style="display: block; width: 2.82rem;margin: 37% auto;" src="/plan/caigou/img/wu.png">';

                                $("#pro1").html(str);
                            } else{
                                jsonData.counter++;
                                $("#pro1").append(str);
                            }

                            if (data.list.length!=4){
                                me.lock();
                                // 无数据
                                me.noData(true);
                            }else{

                                me.resetload();
                            }


                        }else{
                            me.lock();
                            // 无数据
                            me.noData();
                        }

                    },
                    error: function(xhr, type) {
                        me.lock();
                        // 无数据
                        me.noData();
                        me.resetload();
                    }
                })

            }
        });

    }
    //重载产品数据
    function overProduct() {

        $.ajax({
            type:"post",
            url:"/index/outpur/xsindex",
            data:jsonData,
            success:function (data) {
                if (data.list!=null){
                    jsonData.counter++;
                    let str=getList(data.list);
                    if (data.list.length==0){
                        str='<img style="display: block; width: 2.82rem;margin: 37% auto;" src="/plan/caigou/img/wu.png">';
                    }
                    $("#pro1").html(str);
                    $("#pro1").show();
                    if (data.list.length!=4){

                        meLoad.lock();
                        // 无数据
                        meLoad.noData();
                    }else{
                        meLoad.unlock();
                        meLoad.noData(false);
                        meLoad.resetload();
                    }



                }

            }

        })
    }
    function goBack(id) {

        location.href="/index/outpur/xsview/id/"+id;
    }
    function getList(data) {
        var str='';
        data.forEach(function (e,i) {
            str+='<li onclick="goBack('+e.id+')">\n' +
                '                <p class="number">\n' +
                '                    单据编号：<span style="color: #333;font-size: 0.3rem;">'+e.order_id+'</span>\n' +
                '                    '+e.status+'\n' +
                '                </p>\n' +
                '                <p class="info">客户名称：'+e.khmc+'</p>\n' +
                '                <p class="info">当前仓库：'+e.cname+'</p>\n'+
                '                <div class="date">\n' +
                '                    <span class="date_left">创建人：'+e.publisher+'</span>\n' +
                '                    <span class="date_right">'+e.createtime+'</span>\n' +
                '                </div>\n' +
                '        </li>';
        });
        return str;
    }
</script>


</html>
